{% extends "compose.html" %}

{% block title %} admin - compose {% end %}

{% block header %}
admin
{% end %}

{% block imenu %}
<div class="aeCompose">
  <div class="row">
	<div class="imenu">
	  <a href="/a/posts/">publish</a> | <a href="/a/posts/private/">private</a> | <a href="/a/posts/draft/">draft</a>
	</div>
  </div>
</div>
{% end %}

{% block body %}
<div class="aePosts">
  <h2>{{ action }}</h2>
  <table width="100%" cellspacing="0" cellpadding="5" border="0" class="data">
	<thead>
	  <tr>
		<td width="500">title</td><td>date</td><td></td>
	  </tr>
	</thead>
	<tbody>
	  {% for post in posts['rowset'] %}
	  <tr onmouseover="mover(this)" onmouseout="mout(this)">
			<td><a href="/a/post/{{ post['_id'] }}">{{ post['title'] }}</a></td>
		<td> <span style="font-size:8pt"> {{ post['ctime'] }} </span> <br /> <span style="color:#ccc;font-size:8pt"> {{ (lambda c,m:m or c)(post['ctime'],post['mtime']) }}</span>
		</td>
		<td>
		  <a href="javascript:void(0)" onclick="top('{{ post['_id'] }}')" class="btn {% if post['top']==1 %}sl{% end %}"> Top </a>
		  <a href="javascript:void(0)" onclick="" class="btn"> Publish </a>
		  <a href="javascript:void(0)" onclick="" class="btn"> Private </a>
		  <a href="javascript:void(0)" onclick="" class="btn"> Draft </a>
		  <a href="javascript:void(0)" onclick="del('{{ post['_id'] }}')" class="btn red"> Trash </a>
		</td>
	  </tr>
	  {% end %}
	  <tr>
		<td colspan="4" align="right">{{ modules.Page(posts,limit=30) }}</td>
	  </tr>
	</tbody>
  </table>
</div>

{% end %}

{% block initscript %}

function mover(ob){
$(ob).css('background-color',"#EEE");
}

function mout(ob){
$(ob).css('background-color',"#FFF");
}
function top(pid){
$.post(location.href,{postid:pid,action:"top",_xsrf:"{{ xsrf_token }}"},function(data){
location.reload();
});
}

function del(pid){
$.post(location.href,{postid:pid,action:"delete",_xsrf:"{{ xsrf_token }}"},function(data){
location.reload();
});
}
{% end %}

